/**
 * 获取时间
 * @param dayCount
 */
export function getDate(dayCount) {
    //获取当前时间
    let date = new Date()
    date.setDate(date.getDate() + dayCount)
    //获取当前年份
    let year = date.getFullYear()
    //获取当前月份，不足10不零
    let months = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1)
    //获取当前几号
    let days = date.getDate() - 2 < 10 ? "0" + (date.getDate() - 2) : (date.getDate() - 2)
    // //获取当前几号
    // let days = date.getDate() < 10 ? "0" + date.getDate() : date.getDate()
    // console.log(days - 2, days);
    let _date = new Date(year, months - 1, days)
    let week
    if (_date.getDay() == 0) week = "周日";
    if (_date.getDay() == 1) week = "周一";
    if (_date.getDay() == 2) week = "周二";
    if (_date.getDay() == 3) week = "周三";
    if (_date.getDay() == 4) week = "周四";
    if (_date.getDay() == 5) week = "周五";
    if (_date.getDay() == 6) week = "周六";
    let timestamp = _date.getTime()
    return {
        year, months, days, week, timestamp
    }
}

/**
 * 生成预约时间表
 * @param timestamp
 */
export function generateTime(timestamp) {
    let timeList = [
        { time: '8:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(8), disable: false },
        { time: '9:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(9), disable: false },
        { time: '10:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(10), disable: false },
        { time: '11:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(11), disable: false },
        { time: '13:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(13), disable: false },
        { time: '14:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(14), disable: false },
        { time: '15:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(15), disable: false },
        { time: '16:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(16), disable: false },
        { time: '17:00', surplus: 15, active: false, timestamp: hourChangeTimestamp(17), disable: false }
    ]
    let current_timestamp = new Date().getTime()
    for (let i = 0; i < timeList.length; i++) {
        let pendingTimestamp = timestamp + timeList[i].timestamp + hourChangeTimestamp(1)
        // if (current_timestamp > pendingTimestamp) {
        //   timeList[i].disable = true
        // } else {
        //   timeList[i].disable = false
        // }
    }
    return timeList
}

/**
 * 小时转换为时间戳
 * @param hour
 */
export function hourChangeTimestamp(hour) {
    return hour * 60 * 60 * 1000
}